<?php
/* 
 * Copyright (c) 2018-2021   All rights reserved.
 * 
 * 创建时间：2021-05-23 09:55
 *
 * 项目：upload  -  $  - levmodules.php
 *
 * 作者：liwei 
 */

namespace modules\levpays\modules\baidupay;

use Lev;
use lev\helpers\UrlHelper;

!defined('INLEV') && exit('Access Denied LEV');

class baidupayHelper extends \lev\base\Modulesv
{

    public static $mud = [
        'version' => '1.0.210923',
    ];

    public static function init()
    {
        parent::init(); // TODO: Change the autogenerated stub
        //Assetsv::registerApp(static::$mud['version']);

    }

    public static function urlQrcodeAuth() {
        return Lev::toRoute(['/'.static::myGateFile(), 'type'=>'qrcode-auth']);
    }

    public static function urlQrcodePay($tradeId) {
        $redirect = Lev::base64_encode_url(UrlHelper::payTrade(0, null, null, $tradeId));
        return Lev::toRoute(['/'.static::myGateFile(), 'type'=>'qrcode-pay', 'redirect'=>$redirect]);
    }

    public static function myGateFile() {
        return 'baidu_pay_notify.php';
    }

    public static function checkBaiduUserAgent() {
        return Lev::ckUserAgent('baiduboxapp/');
    }
    public static function checkBaiduMiniUserAgent() {
        return Lev::ckUserAgent('swan-baiduboxapp/');
    }
}